package main

import (
	"log"
	"math/rand"
	"os"
	"text/template"
	"time"
)

type AgeInfo struct {
	Age           int
	GreaterThan60 bool
	GreaterThan40 bool
}

func getTemplate(dir string) *template.Template {
	t, _ := template.ParseFiles(dir)
	return t
}
func main() {
	//t, err := template.ParseFiles("go_basic/template/test")
	//if err != nil {
	//	log.Fatal("Parse error:", err)
	//}
	t := getTemplate("go_basic/template/test")
	rand.Seed(time.Now().Unix())
	age := rand.Intn(100)
	info := AgeInfo{
		Age:           age,
		GreaterThan60: age > 60,
		GreaterThan40: age > 40,
	}
	var err = t.Execute(os.Stdout, info)
	if err != nil {
		log.Fatal("Execute error:", err)
	}
}
